package com.hongmeng.web.controller.operater.moduleResource;

import java.util.List;

import com.hongmeng.operater.domain.moduleResource.HmModuleResource;
import com.hongmeng.operater.domain.moduleResource.entity.QueryModuleEntity;
import com.hongmeng.operater.domain.moduleResource.entity.QueryModuleReturnEntity;
import com.hongmeng.operater.service.moduleResource.IHmModuleResourceService;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hongmeng.common.annotation.Log;
import com.hongmeng.common.core.controller.BaseController;
import com.hongmeng.common.core.domain.AjaxResult;
import com.hongmeng.common.enums.BusinessType;
import com.hongmeng.common.core.page.TableDataInfo;

/**
 * 模块资源Controller
 *
 * @author hongmeng
 * @date 2021-01-04
 */
@ApiOperation("模块资源Controller")
@RestController
@RequestMapping("/operater/moduleResource")
public class HmModuleResourceController extends BaseController {
    @Autowired
    private IHmModuleResourceService hmModuleResourceService;

    /**
     * 查询模块资源列表
     */
    @ApiOperation("查询模块资源列表")
    @PreAuthorize("@ss.hasPermi('operater:moduleResource:list')")
    @GetMapping("/list")
    public TableDataInfo list(QueryModuleEntity hmModuleResource) {
        startPage();
        List<QueryModuleReturnEntity> list = hmModuleResourceService.selectHmModuleResourceList(hmModuleResource);
        return getDataTable(list);
    }

    /**
     * 获取模块资源详细信息
     */
    @ApiOperation("获取模块资源详细信息")
    @PreAuthorize("@ss.hasPermi('operater:moduleResource:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return hmModuleResourceService.selectHmModuleResourceById(id);
    }

    /**
     * 新增模块资源
     */
    @ApiOperation("新增模块资源")
    @PreAuthorize("@ss.hasPermi('operater:moduleResource:add')")
    @Log(title = "模块资源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HmModuleResource hmModuleResource) {
        return toAjax(hmModuleResourceService.insertHmModuleResource(hmModuleResource));
    }

    /**
     * 修改模块资源
     */
    @ApiOperation("修改模块资源")
    @PreAuthorize("@ss.hasPermi('operater:moduleResource:edit')")
    @Log(title = "模块资源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HmModuleResource hmModuleResource) {
        return toAjax(hmModuleResourceService.updateHmModuleResource(hmModuleResource));
    }

    /**
     * 删除模块资源
     */
    @ApiOperation("删除模块资源")
    @PreAuthorize("@ss.hasPermi('operater:moduleResource:remove')")
    @Log(title = "模块资源", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(hmModuleResourceService.deleteHmModuleResourceByIds(ids));
    }
}
